package org.framework.lazy.cloud.network.heartbeat.server.standalone.application.impl;

import jakarta.annotation.Resource;
import org.framework.lazy.cloud.network.heartbeat.server.standalone.application.LazyNettyClientVirtualRouteApplication;
import org.framework.lazy.cloud.network.heartbeat.server.standalone.application.assembler.LazyNettyClientVirtualRouteDTOAssembler;
import org.framework.lazy.cloud.network.heartbeat.server.standalone.application.command.lazy.netty.client.virtual.route.*;
import org.framework.lazy.cloud.network.heartbeat.server.standalone.application.dto.LazyNettyClientVirtualRouteDTO;
import org.framework.lazy.cloud.network.heartbeat.server.standalone.domain.model.lazy.netty.client.virtual.route.LazyNettyClientVirtualRoute;
import org.framework.lazy.cloud.network.heartbeat.server.standalone.domain.model.lazy.netty.client.virtual.route.LazyNettyClientVirtualRouteRepository;
import org.wu.framework.lazy.orm.database.lambda.domain.LazyPage;
import org.wu.framework.lazy.orm.web.plus.stereotype.LazyApplication;
import org.wu.framework.web.response.Result;

import java.util.List;
import java.util.stream.Collectors;

/**
 * describe 客户端虚拟路由管理
 *
 * @author Jia wei Wu
 * @date 2025/05/06 05:00 下午
 * @see org.wu.framework.lazy.orm.core.persistence.reverse.lazy.ddd.DefaultDDDLazyApplicationImpl
 **/
@LazyApplication
public class LazyNettyClientVirtualRouteApplicationImpl implements LazyNettyClientVirtualRouteApplication {

    @Resource
    LazyNettyClientVirtualRouteRepository lazyNettyClientVirtualRouteRepository;

    /**
     * describe 新增客户端虚拟路由管理
     *
     * @param lazyNettyClientVirtualRouteStoryCommand 新增客户端虚拟路由管理
     * @return {@link Result<LazyNettyClientVirtualRoute>} 客户端虚拟路由管理新增后领域对象
     * @author Jia wei Wu
     * @date 2025/05/06 05:00 下午
     **/

    @Override
    public Result<LazyNettyClientVirtualRoute> story(LazyNettyClientVirtualRouteStoryCommand lazyNettyClientVirtualRouteStoryCommand) {
        LazyNettyClientVirtualRoute lazyNettyClientVirtualRoute = LazyNettyClientVirtualRouteDTOAssembler.INSTANCE.toLazyNettyClientVirtualRoute(lazyNettyClientVirtualRouteStoryCommand);
        return lazyNettyClientVirtualRouteRepository.story(lazyNettyClientVirtualRoute);
    }

    /**
     * describe 批量新增客户端虚拟路由管理
     *
     * @param lazyNettyClientVirtualRouteStoryCommandList 批量新增客户端虚拟路由管理
     * @return {@link Result<List<LazyNettyClientVirtualRoute>>} 客户端虚拟路由管理新增后领域对象集合
     * @author Jia wei Wu
     * @date 2025/05/06 05:00 下午
     **/

    @Override
    public Result<List<LazyNettyClientVirtualRoute>> batchStory(List<LazyNettyClientVirtualRouteStoryCommand> lazyNettyClientVirtualRouteStoryCommandList) {
        List<LazyNettyClientVirtualRoute> lazyNettyClientVirtualRouteList = lazyNettyClientVirtualRouteStoryCommandList.stream().map(LazyNettyClientVirtualRouteDTOAssembler.INSTANCE::toLazyNettyClientVirtualRoute).collect(Collectors.toList());
        return lazyNettyClientVirtualRouteRepository.batchStory(lazyNettyClientVirtualRouteList);
    }

    /**
     * describe 更新客户端虚拟路由管理
     *
     * @param lazyNettyClientVirtualRouteUpdateCommand 更新客户端虚拟路由管理
     * @return {@link Result<LazyNettyClientVirtualRoute>} 客户端虚拟路由管理领域对象
     * @author Jia wei Wu
     * @date 2025/05/06 05:00 下午
     **/

    @Override
    public Result<LazyNettyClientVirtualRoute> updateOne(LazyNettyClientVirtualRouteUpdateCommand lazyNettyClientVirtualRouteUpdateCommand) {
        LazyNettyClientVirtualRoute lazyNettyClientVirtualRoute = LazyNettyClientVirtualRouteDTOAssembler.INSTANCE.toLazyNettyClientVirtualRoute(lazyNettyClientVirtualRouteUpdateCommand);
        return lazyNettyClientVirtualRouteRepository.story(lazyNettyClientVirtualRoute);
    }

    /**
     * describe 查询单个客户端虚拟路由管理
     *
     * @param lazyNettyClientVirtualRouteQueryOneCommand 查询单个客户端虚拟路由管理
     * @return {@link Result<LazyNettyClientVirtualRouteDTO>} 客户端虚拟路由管理DTO对象
     * @author Jia wei Wu
     * @date 2025/05/06 05:00 下午
     **/

    @Override
    public Result<LazyNettyClientVirtualRouteDTO> findOne(LazyNettyClientVirtualRouteQueryOneCommand lazyNettyClientVirtualRouteQueryOneCommand) {
        LazyNettyClientVirtualRoute lazyNettyClientVirtualRoute = LazyNettyClientVirtualRouteDTOAssembler.INSTANCE.toLazyNettyClientVirtualRoute(lazyNettyClientVirtualRouteQueryOneCommand);
        return lazyNettyClientVirtualRouteRepository.findOne(lazyNettyClientVirtualRoute).convert(LazyNettyClientVirtualRouteDTOAssembler.INSTANCE::fromLazyNettyClientVirtualRoute);
    }

    /**
     * describe 查询多个客户端虚拟路由管理
     *
     * @param lazyNettyClientVirtualRouteQueryListCommand 查询多个客户端虚拟路由管理
     * @return {@link Result<List<LazyNettyClientVirtualRouteDTO>>} 客户端虚拟路由管理DTO对象
     * @author Jia wei Wu
     * @date 2025/05/06 05:00 下午
     **/

    @Override
    public Result<List<LazyNettyClientVirtualRouteDTO>> findList(LazyNettyClientVirtualRouteQueryListCommand lazyNettyClientVirtualRouteQueryListCommand) {
        LazyNettyClientVirtualRoute lazyNettyClientVirtualRoute = LazyNettyClientVirtualRouteDTOAssembler.INSTANCE.toLazyNettyClientVirtualRoute(lazyNettyClientVirtualRouteQueryListCommand);
        return lazyNettyClientVirtualRouteRepository.findList(lazyNettyClientVirtualRoute).convert(lazyNettyClientVirtualRoutes -> lazyNettyClientVirtualRoutes.stream().map(LazyNettyClientVirtualRouteDTOAssembler.INSTANCE::fromLazyNettyClientVirtualRoute).collect(Collectors.toList()));
    }

    /**
     * describe 分页查询多个客户端虚拟路由管理
     *
     * @param lazyNettyClientVirtualRouteQueryListCommand 分页查询多个客户端虚拟路由管理
     * @return {@link Result<LazyPage<LazyNettyClientVirtualRouteDTO>>} 分页客户端虚拟路由管理DTO对象
     * @author Jia wei Wu
     * @date 2025/05/06 05:00 下午
     **/

    @Override
    public Result<LazyPage<LazyNettyClientVirtualRouteDTO>> findPage(int size, int current, LazyNettyClientVirtualRouteQueryListCommand lazyNettyClientVirtualRouteQueryListCommand) {
        LazyNettyClientVirtualRoute lazyNettyClientVirtualRoute = LazyNettyClientVirtualRouteDTOAssembler.INSTANCE.toLazyNettyClientVirtualRoute(lazyNettyClientVirtualRouteQueryListCommand);
        return lazyNettyClientVirtualRouteRepository.findPage(size, current, lazyNettyClientVirtualRoute).convert(page -> page.convert(LazyNettyClientVirtualRouteDTOAssembler.INSTANCE::fromLazyNettyClientVirtualRoute));
    }

    /**
     * describe 删除客户端虚拟路由管理
     *
     * @param lazyNettyClientVirtualRouteRemoveCommand 删除客户端虚拟路由管理
     * @return {@link Result<LazyNettyClientVirtualRoute>} 客户端虚拟路由管理
     * @author Jia wei Wu
     * @date 2025/05/06 05:00 下午
     **/

    @Override
    public Result<LazyNettyClientVirtualRoute> remove(LazyNettyClientVirtualRouteRemoveCommand lazyNettyClientVirtualRouteRemoveCommand) {
        LazyNettyClientVirtualRoute lazyNettyClientVirtualRoute = LazyNettyClientVirtualRouteDTOAssembler.INSTANCE.toLazyNettyClientVirtualRoute(lazyNettyClientVirtualRouteRemoveCommand);
        return lazyNettyClientVirtualRouteRepository.remove(lazyNettyClientVirtualRoute);
    }

}